﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace ImbedLibrary
{
    public static class FolderHelper
    {
        /// <summary>
        /// 修复文件夹路径
        /// </summary>
        /// <param name="path">路径  c:\temp</param>
        /// <returns>c:\temp\</returns>
        public static string Format(string path)
        {
            if (path.LastIndexOf("\\") + 1 == path.Length) return path;
            else return path + "\\";
        }

        /// <summary>
        /// 创建隐藏的文件夹
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static void CreateHidden(string path)
        {
            if (Directory.Exists(path))
            {
                FileAttributes myAttributes = File.GetAttributes(path);
                if (myAttributes.ToString().IndexOf("Hidden") == -1)
                    File.SetAttributes(path, FileAttributes.Hidden);
            }
            else
            {
                DirectoryInfo info = Directory.CreateDirectory(path);
                info.Attributes = FileAttributes.Hidden;
            }
        }
    }
}
